{extend name="common/index"}
{block name="css"}

{/block}
{block name="content"}



<!--sub_nav-->
<div class="sub_nav">
    <div class="wrap clear">
        <p>你在这里：</p>
        <a href="{:url('index/index')}">首页</a> >
        <a class="on" href="javascript:void(0);">防伪查询</a>
    </div>
</div>

<!--anti-->
<div class="anti">
    <div class="wrap">
        <div class="anti_nav">
            <ul class="clear">
                <li class="on"><a href="javascript:void(0);">防伪查询</a></li>
                <li><a href="anti_b.html">标签使用说明</a></li>
            </ul>
        </div>
        <div class="anti_wrap clear">
            <div class="fl anti_l">
                <h3>消费者防伪查询</h3>
                <h4>请揭起标签输入底层16位防伪码进行查询</h4>
                <p>本标签共有2层，第一层为物流追溯标，第二层为防伪标。</p>
                <p>掀开第一层标签，即可在第二层上找到16位防伪码，输入即可查询真伪。</p>
                <div class="queryCon">
                    <input type="text" name="AntiCode" id="AntiCode" maxlength="19" onkeyup="addSpace1(this)" placeholder="请输入16位防伪码" class="inputBox" /><!--控件的名称请不要变更-->
                    <div class="queryBtn"><input type="button" value="查询" id="btnQuery"><input type="button" value="重置" onclick="document.getElementById('AntiCode').value=''"></div>
                </div>
                <!--<form>
                    <input id="AntiCode" type="text" placeholder="请输入16位防伪码"/>
                    <div class="btns">
                        <input type="button" value="查询" id="btnQuery"/>
                        <input type="reset" value="重置"/>
                    </div>
                </form>-->
            </div>
            <div class="fr anti_r">
                <div class="img">
                    <img src="__SHOUCAI__/images/anti_01.jpg" alt=""/>
                </div>
                <p>标签表层(请揭开留底层查真伪)</p>
                <div class="img">
                    <img src="__SHOUCAI__/images/anti_02.jpg" alt=""/>
                </div>
                <p>标签底层(请揭开留底层查真伪)</p>
            </div>
        </div>
        <!--查询结果-->
        <div id="ShowResult" style="margin: 50px 0px 0px 0px; display: none;">&nbsp;</div>

        <!--<div class="anti_result clear show">
            <div class="icon fl"><img src="__SHOUCAI__/images/anti_03.jpg" alt=""/></div>
            <div class="fl txt">
                <h3><b>查询编码：</b>0308564904195288</h3>
                <p>您所查询的是正牌产品编码，谢谢查询！</p>
                <p>该编码已被查询，现在是<span>第2次</span>查询！</p>
                <p>查询记录：</p>
                <p><span>2018年6月27日 17时51分27秒，首次查询。查询方式：网页查询</span></p>
            </div>
        </div>-->
    </div>
</div>
{/block}
{block name="script"}

<script language="JavaScript" type="text/javascript">
    function addSpace1(objText) {
        var code = objText.value;
        re = / /gi;
        code = code.replace(re, "");
        var length = code.length;

        if (length > 4 && length <= 8) {
            code = code.substr(0, 4) + " " + code.substr(4);
        }
        else if (length > 8 && length <= 12) {
            code = code.substr(0, 4) + " " + code.substr(4, 4) + " " + code.substr(8);
        } else if (length > 12 && length <= 18) {
            code = code.substr(0, 4) + " " + code.substr(4, 4) + " " + code.substr(8, 4) + " " + code.substr(12);
        }
        objText.value = code;
    }
    //显示正确的结果
    function success(code, data) {
        return "<div style='margin:0px 0;padding:10px 10px;'><table width='100%'  border='0' align='center' cellpadding='0' cellspacing='0'><tr><td width='12%'><img src='__SHOUCAI__/images/" + data.QueryResult + ".png' /></td><td style='color:#333;font-size:18px;'><b>查询编码：</b>" + code + "<br /><br /><div class='myrow' style='color:#333;font-size: 14px;'>" + data.Result + "</div></td></tr></table></div>";//<a href='Default.htm' style='color:#da251c;text-decoration: none;'>点此返回</a>
    }
    var waitingHtml = "<div style='margin:20px 0;padding:20px 10px;'><img src='__SHOUCAI__/images/ajax_loading.gif' style='vertical-align:middle;position:relative;top:-3px;' />&nbsp;系统查询中，请稍后 ...</div>";
    var errorHtml = "<div style='margin:20px 0;padding:20px 10px;'><img src='__SHOUCAI__/images/5.png' style='vertical-align:middle;position:relative;top:-3px;' />抱歉，系统出错，如需帮助请联系 4008 800 939&nbsp;&nbsp; <a href='Default.htm' style='color:#da251c;text-decoration: none;'>点此返回</a></div>";
    $(function () {
        $("#btnQuery").click(function () {
            var EnterpriseCode = "195"; //请不要更改
            var LanguageType = "1"; //
            var AntiCode = $.trim($("#AntiCode").val()); //获取防伪码
            re = / /gi;
            AntiCode = AntiCode.replace(re, "");
            if (AntiCode.length != 16) {
                alert("请输入16位防伪码");
                return false;
            }
            //                document.getElementById("tabquery1").style.display = "none"; //查询隐藏
            document.getElementById("ShowResult").style.display = ""; //结果显示
            $("#ShowResult").html(waitingHtml);

            var dataStr = "EnterpriseCode=" + EnterpriseCode + "&AntiCode=" + AntiCode + "&LanguageType=" + LanguageType;
            $.ajax({
                type: "get",
                url: "http://www.4008863456.com/codequery/WebService/AntiService.asmx/AntiWebQuery_Ajax?jsoncallback?",
                dataType: "jsonp",
                jsonp: 'jsoncallback',
                data: dataStr,
                success: function (result) {
                    //返回查询结果
                    $("#ShowResult").html(success(AntiCode, result));
                    $("#AntiCode").val(""); //清除输入框
                },
                error: function (result, status) {
                    if (status == 'error') {
                        $("#ShowResult").html(errorHtml);
                    }
                }
            });
        });
    });
</script>

{/block}
